<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="上报时间">
        <el-date-picker
          v-model="daterangeReportingDate"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="机台号" prop="machineryCode">
        <el-input v-model="queryParams.machineryCode" placeholder="请输入机台号" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="设备名称" prop="machineryName">
        <el-input v-model="queryParams.machineryName" placeholder="请输入设备类型名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <el-form-item label="带班机长" prop="leader">
        <el-input v-model="queryParams.leader" placeholder="请输入带班机长" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="工作单号" prop="workorderId">
        <el-input v-model="queryParams.workorderId" placeholder="请输入工作单号" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="工单名称" prop="workorderName">
        <el-input v-model="queryParams.workorderName" placeholder="请输入生产工单名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <!-- <el-form-item label="原纸卷号" prop="rollNumber">
        <el-input v-model="queryParams.rollNumber" placeholder="请输入原纸卷号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="产品编码" prop="itemCode">
        <el-input v-model="queryParams.itemCode" placeholder="请输入产品物料编码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <el-form-item label="产品名称" prop="itemName">
        <el-input v-model="queryParams.itemName" placeholder="请输入产品名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="班次" prop="workGroup" class="upTime">
        <el-select v-model="queryParams.workGroup" placeholder="请选择班次" clearable>
            <el-option :label="item.value" :value="item.value"  v-for="item in workGroupList" :key="item.value"/>
          </el-select>
        <!-- <el-input v-model="queryParams.workGroup" placeholder="请输入班次" clearable @keyup.enter.native="handleQuery" /> -->
      </el-form-item>
      <el-form-item label="工种" prop="profession">
        <el-input v-model="queryParams.profession" placeholder="请输入工种" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="助1" prop="assistant1">
        <el-input v-model="queryParams.assistant1" placeholder="请输入助1" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="助2" prop="assistant2">
        <el-input v-model="queryParams.assistant2" placeholder="请输入助2" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="报表号" prop="reportNo">
        <el-input v-model="queryParams.reportNo" placeholder="请输入报表号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户编码" prop="clientCode">
        <el-input v-model="queryParams.clientCode" placeholder="请输入客户编码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户名称" prop="clientName">
        <el-input v-model="queryParams.clientName" placeholder="请输入客户名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="设备类型编码" prop="machineryTypeCode">
        <el-input v-model="queryParams.machineryTypeCode" placeholder="请输入设备类型编码" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="设备类型名称" prop="machineryTypeName">
        <el-input v-model="queryParams.machineryTypeName" placeholder="请输入设备类型名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="报工状态" prop="fbStatus">
        <el-select v-model="queryParams.fbStatus" placeholder="请选择报工状态" clearable>
          <el-option
            v-for="dict in dict.type.mes_fb_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['fb:reel:add']">新增</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['fb:reel:remove']">删除</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['fb:reel:export']">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport"
          v-hasPermi="['fb:reel:import']">导入</el-button>
      </el-col>
      
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!-- <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
          </div> -->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
            @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-table v-loading="loading" :data="reelList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="记录ID" align="center" prop="recordId" fixed="left" /> -->
      <!-- <el-table-column label="原纸卷号" align="center" prop="rollNumber" fixed="left" /> -->
      <!-- <el-table-column label="设备类型ID" align="center" prop="machineryId" /> -->
      <el-table-column label="年" align="center" prop="year"  fixed="left"/>
      <el-table-column label="月" align="center" prop="month"  fixed="left"/>
      <el-table-column label="日" align="center" prop="day"  fixed="left"/>
      <el-table-column label="机台号" align="center" prop="machineryCode" fixed="left" />
      <!-- <el-table-column label="设备名称" align="center" prop="machineryName" fixed="left" /> -->
      <el-table-column label="带班机长" align="center" prop="leader" fixed="left" />
      <!-- <el-table-column label="生产工单ID" align="center" prop="workorderId" /> -->
      <el-table-column label="工作单号" align="center" prop="workorderId" fixed="left" />
      <!-- <el-table-column label="工单名称" align="center" prop="workorderName" fixed="left" /> -->
      <!-- <el-table-column label="生产任务ID" align="center" prop="taskId" /> -->
      <!-- <el-table-column label="生产任务编号" align="center" prop="taskCode" /> -->
      <!-- <el-table-column label="产品物料ID" align="center" prop="itemId" /> -->
      <el-table-column label="产品编号" fixed align="center" prop="itemCode" />
      <el-table-column label="制袋数" align="center" prop="bagNumber" />
      <el-table-column label="制袋米数" align="center" prop="bagMeters" />
      <el-table-column label="班次" align="center" prop="workGroup" />
      <el-table-column label="废袋数" align="center" prop="bagWasteNumber" />
      <el-table-column label="印废" align="center" prop="printingWasteNumber" />
      <el-table-column label="返修" align="center" prop="reworkNumber" />
      <el-table-column label="料头重" align="center" prop="materialHeadWeight" />

      <el-table-column label="印废磅重" align="center" prop="printWasteWeight" />
      <!-- 印废磅重 -->

      <!-- <el-table-column label="成型拉料/KG" align="center" prop="formingMaterial" /> -->
      <el-table-column label="废袋重" align="center" prop="bagWasteWeight" />
      <el-table-column label="废重换算" align="center" prop="wasteWeight" />
      <el-table-column label="合格数" align="center" prop="quantityQualified" />
      <el-table-column label="产品单重" align="center" prop="itemWeight" />
      <el-table-column label="机台运行情况" align="center" prop="proSituation" width="180" show-overflow-tooltip />
      <el-table-column label="换规格" align="center" prop="changeSpc" />
      <el-table-column label="计时" align="center" prop="hour" />
      <el-table-column label="异常停机" align="center" prop="abnormalShutdown" />
      <el-table-column label="工种" align="center" prop="profession" />
      <el-table-column label="考勤时间" align="center" prop="attendanceTime" />
      <el-table-column label="一助" align="center" prop="assistant1" />
      <el-table-column label="考勤时间" align="center" prop="attendanceTime1" />
      <el-table-column label="二助" align="center" prop="assistant2" />
      <el-table-column label="考勤时间" align="center" prop="attendanceTime2" />
      <el-table-column label="调机补助" align="center" prop="adjustmentSubsidy" />
      <!-- 调机补助 adjustmentSubsidy -->

      <el-table-column label="机长" align="center" prop="leaderWages" />
      <el-table-column label="一助" align="center" prop="assistant1Wages" />
      <el-table-column label="二助" align="center" prop="assistant2Wages" />
      <el-table-column label="作业人数" align="center" prop="workerNumber" />
      <el-table-column label="计件工资" align="center" prop="wages" />
      <el-table-column label="报表号" align="center" prop="reportNo" />
      <el-table-column label="产品名称" width="130"  align="center" prop="itemName" />
      <el-table-column label="客户" width="130"  align="center" prop="clientName" />
      <el-table-column label="机型" width="130" align="center" prop="machineryTypeCode" />
      <!-- 客户
      机型 -->
      <!-- <el-table-column label="客户ID" align="center" prop="clientId" /> -->
      <!-- <el-table-column label="客户编码" align="center" prop="clientCode" />
      <el-table-column label="客户名称" align="center" prop="clientName" /> -->
      <!-- <el-table-column label="设备类型ID" align="center" prop="machineryTypeId" /> -->
      <!-- <el-table-column label="设备类型编码" align="center" prop="machineryTypeCode" />
      <el-table-column label="设备类型名称" align="center" prop="machineryTypeName" />
      <el-table-column label="报工状态" align="center" prop="fbStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.mes_fb_status" :value="scope.row.fbStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip /> -->
      <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width"  fixed="right" >
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-if="scope.row.fbStatus !== 2"
            v-hasPermi="['fb:reel:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-if="scope.row.fbStatus !== 2"
            v-hasPermi="['fb:reel:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改卷筒机报对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1100px" append-to-body>
      <el-form ref="form" inline :model="form" :rules="rules" label-width="120px">
        <!-- <el-form-item label="设备ID" prop="machineryId">
          <el-input v-model="form.machineryId" placeholder="请输入设备类型ID" />
        </el-form-item> -->
        <el-form-item label="年" prop="year">
          <el-input v-model="form.year" type="number" placeholder="请输入年" />
        </el-form-item>
        <el-form-item label="月" prop="month">
          <el-input v-model="form.month" type="number" placeholder="请输入月" />
        </el-form-item>
        <el-form-item label="日" prop="day">
          <el-input v-model="form.day" type="number" placeholder="请输入日" />
        </el-form-item>
        <el-form-item label="机台号" prop="machineryCode">
          <!-- <el-input v-model="form.machineryCode" placeholder="请输入设备类型编码" /> -->
          <el-input v-model="form.machineryCode" style="width: 200px;" placeholder="请输入机台号" readonly="readonly">
            <el-button slot="append" style="width: 30px; padding: 10px;" @click="handleMachineryAdd"
              icon="el-icon-search"></el-button>
          </el-input>
          <MachinerySelectSingle ref="machinerySelect" @onSelected="onMachineryAdd"></MachinerySelectSingle>
        </el-form-item>
        <!-- <el-form-item label="设备名称" prop="machineryName">
          <el-input v-model="form.machineryName" placeholder="请输入设备类型名称" />
        </el-form-item> -->

        <!-- <el-form-item label="生产工单ID" prop="workorderId">
          <el-input v-model="form.workorderId" placeholder="请输入生产工单ID" />
        </el-form-item> -->
        <el-form-item label="带班机长" prop="leader">
          <el-input v-model="form.leader" placeholder="请输入带班机长" />
        </el-form-item>
        <el-form-item label="工作单号" prop="workorderCode">
          <!-- <el-input v-model="form.workorderCode" placeholder="请输入生产工单编号" /> -->
          <el-input v-model="form.workorderCode" style="width: 200px;" placeholder="请输入工作单号">
            <el-button slot="append" style="width: 30px; padding: 10px;" icon="el-icon-search"
              @click="handleWorkorderSelect"></el-button>
          </el-input>
          <WorkorderSelect ref="woSelect" @onSelected="onWorkorderSelected"></WorkorderSelect>
        </el-form-item>
        <!-- <el-form-item label="生产工单名称" prop="workorderName">
          <el-input v-model="form.workorderName" placeholder="请输入生产工单名称" />
        </el-form-item> -->
        <el-form-item label="产品编号" prop="itemCode">
          <el-input v-model="form.itemCode" placeholder="请输入产品编号" />
        </el-form-item>
        <!-- <el-form-item label="生产任务ID" prop="taskId">
          <el-input v-model="form.taskId" placeholder="请输入生产任务ID" />
        </el-form-item> -->
        <!-- <el-form-item label="生产任务编号" prop="taskCode">
          <el-input v-model="form.taskCode" placeholder="请输入生产任务编号" />
        </el-form-item> -->

        <!-- <el-form-item label="产品物料ID" prop="itemId">
          <el-input v-model="form.itemId" placeholder="请输入产品物料ID" />
        </el-form-item> -->
        <!--         <el-form-item label="原纸卷号" prop="rollNumber">
          <el-input v-model="form.rollNumber" placeholder="请输入原纸卷号" />
        </el-form-item>
        <el-form-item label="产品物料名称" prop="itemName">
          <el-input v-model="form.itemName" placeholder="请输入产品物料名称" />
        </el-form-item> -->
        <el-form-item label="制袋数" prop="bagNumber">
          <el-input v-model="form.bagNumber" type="number"  placeholder="请输入制袋数" />
        </el-form-item>
        <el-form-item label="制袋米数" prop="bagMeters">
          <el-input v-model="form.bagMeters" type="number"  placeholder="请输入制袋米数" />
        </el-form-item>
        <el-form-item label="班次" prop="workGroup" class="upTime">
          <el-select v-model="form.workGroup" placeholder="请选择班次" clearable>
              <el-option :label="item.value" :value="item.value"  v-for="item in workGroupList" :key="item.value"/>
            </el-select>
        </el-form-item>
        <el-form-item label="废袋数" prop="bagWasteNumber">
          <el-input v-model="form.bagWasteNumber" type="number"  placeholder="请输入废袋数" />
        </el-form-item>
        <el-form-item label="印废" prop="printingWasteNumber">
          <el-input v-model="form.printingWasteNumber" type="number"  placeholder="请输入印废" />
        </el-form-item>
        <el-form-item label="返修" prop="reworkNumber">
          <el-input v-model="form.reworkNumber" type="number"  placeholder="请输入返修" />
        </el-form-item>
        <el-form-item label="料头重" prop="materialHeadWeight">
          <el-input v-model="form.materialHeadWeight" type="number"  placeholder="请输入料头重" />
        </el-form-item>
        <el-form-item label="印废磅重" prop="printWasteWeight">
          <el-input v-model="form.printWasteWeight" type="number"  placeholder="请输入印废磅重" />
        </el-form-item>
        <!-- <el-form-item label="成型拉料/KG" prop="formingMaterial">
          <el-input v-model="form.formingMaterial" placeholder="请输入成型拉料/KG" />
        </el-form-item> -->
        <el-form-item label="废袋重" prop="bagWasteWeight">
          <el-input v-model="form.bagWasteWeight" type="number"  placeholder="请输入废袋重" />
        </el-form-item>
        <el-form-item label="废重换算" prop="wasteWeight">
          <el-input v-model="form.wasteWeight" type="number"  placeholder="请输入废重换算" />
        </el-form-item>
        <el-form-item label="合格数" prop="quantityQualified">
          <el-input v-model="form.quantityQualified" type="number"  placeholder="请输入合格数" />
        </el-form-item>
        <el-form-item label="产品单重" prop="itemWeight">
          <el-input v-model="form.itemWeight" type="number"  placeholder="请输入产品单重" />
        </el-form-item>
        <el-form-item label="机台运行情况" prop="proSituation">
          <el-input v-model="form.proSituation" placeholder="请输入机台运行情况" />
        </el-form-item>
        <el-form-item label="换规格" prop="changeSpc">
          <el-input v-model="form.changeSpc" placeholder="请输入换规格" />
        </el-form-item>
        <el-form-item label="计时" prop="hour">
          <el-input v-model="form.hour" type="number"  placeholder="请输入计时" />
        </el-form-item>
        <el-form-item label="异常停机" prop="abnormalShutdown">
          <el-input v-model="form.abnormalShutdown" type="number" placeholder="请输入异常停机" />
        </el-form-item>
        <el-form-item label="工种" prop="profession">
          <el-input v-model="form.profession" placeholder="请输入工种" />
        </el-form-item>
        <el-form-item label="考勤时间"  prop="attendanceTime">
          <el-input v-model="form.attendanceTime" type="number" placeholder="请输入考勤时间" />
        </el-form-item>
        <el-form-item label="一助" prop="assistant1">
          <el-input v-model="form.assistant1" placeholder="请输入一助" />
        </el-form-item>
        <el-form-item label="考勤时间" prop="attendanceTime1">
          <el-input v-model="form.attendanceTime1" type="number"  placeholder="请输入考勤时间" />
        </el-form-item>
        <el-form-item label="二助" prop="assistant2">
          <el-input v-model="form.assistant2" placeholder="请输入二助" />
        </el-form-item>
        <el-form-item label="考勤时间" prop="attendanceTime2">
          <el-input v-model="form.attendanceTime2" type="number" placeholder="请输入考勤时间" />
        </el-form-item>
        <el-form-item label="调机补助" prop="adjustmentSubsidy">
          <el-input v-model="form.adjustmentSubsidy" type="number" placeholder="请输入调机补助" />
        </el-form-item>
       
        <el-form-item label="机长" prop="leaderWages">
          <el-input v-model="form.leaderWages" type="number" placeholder="请输入机长" />
        </el-form-item>
        <el-form-item label="一助" prop="assistant1Wages">
          <el-input v-model="form.assistant1Wages" type="number" placeholder="请输入一助" />
        </el-form-item>
        <el-form-item label="二助" prop="assistant2Wages">
          <el-input v-model="form.assistant2Wages" type="number" placeholder="请输入二助" />
        </el-form-item>
         <el-form-item label="作业人数" prop="workerNumber">
          <el-input v-model="form.workerNumber" type="number" placeholder="请输入作业人数" />
        </el-form-item>
        <el-form-item label="计件工资" prop="wages">
          <el-input v-model="form.wages" type="number" placeholder="请输入计件工资" />
        </el-form-item>
        <el-form-item label="报表号" prop="reportNo">
          <el-input v-model="form.reportNo" type="number" placeholder="请输入报表号" />
        </el-form-item>
        <el-form-item label="产品名称" prop="itemName">
          <el-input v-model="form.itemName" placeholder="请输入产品名称" />
        </el-form-item>
        <el-form-item label="客户" prop="clientName">
          <el-input v-model="form.clientName" placeholder="请输入客户" />
        </el-form-item>
        <el-form-item label="机型" prop="machineryTypeCode">
          <el-input v-model="form.machineryTypeCode" placeholder="请输入机型" />
        </el-form-item>
        <!-- <el-form-item label="客户ID" prop="clientId">
          <el-input v-model="form.clientId" placeholder="请输入客户ID" />
        </el-form-item> -->
        <!-- <el-form-item label="客户编码" prop="clientCode">
          <el-input v-model="form.clientCode" placeholder="请输入客户编码" />
        </el-form-item>
        -->
        <!-- <el-form-item label="设备类型ID" prop="machineryTypeId">
          <el-input v-model="form.machineryTypeId" placeholder="请输入设备类型ID" />
        </el-form-item> -->
        <!-- <el-form-item label="设备类型名称" prop="machineryTypeName">
          <el-input v-model="form.machineryTypeName" placeholder="请输入设备类型名称" />
        </el-form-item> -->
        <!-- <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {
    listReel,
    getReel,
    delReel,
    addReel,
    updateReel
  } from "@/api/mes/fb/reel";
  import { getToken } from "@/utils/auth";
  import MachinerySelectSingle from "@/components/machinerySelect/single.vue";
  import WorkorderSelect from "@/components/workorderSelect/single.vue"
  import {parseTime} from "@/utils/ruoyi";

  export default {
    name: "Reel",
    dicts: ['mes_fb_status'],
    components: {
      MachinerySelectSingle,
      WorkorderSelect
    },
    data() {
      return {
        workGroupList:[
        { value:'A',},
        { value:'B',},
        ],
        daterangeReportingDate:[],
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 卷筒机报表格数据
        reelList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          machineryId: null,
          machineryCode: null,
          machineryName: null,
          leader: null,
          workorderId: null,
          workorderCode: null,
          workorderName: null,
          taskId: null,
          taskCode: null,
          rollNumber: null,
          itemId: null,
          itemCode: null,
          itemName: null,
          bagNumber: null,
          bagMeters: null,
          workGroup: null,
          bagWasteNumber: null,
          printingWasteNumber: null,
          reworkNumber: null,
          materialHeadWeight: null,
          formingMaterial: null,
          bagWasteWeight: null,
          wasteWeight: null,
          quantityQualified: null,
          itemWeight: null,
          proSituation: null,
          changeSpc: null,
          hour: null,
          abnormalShutdown: null,
          profession: null,
          attendanceTime: null,
          assistant1: null,
          attendanceTime1: null,
          assistant2: null,
          attendanceTime2: null,
          workerNumber: null,
          leaderWages: null,
          assistant1Wages: null,
          assistant2Wages: null,
          wages: null,
          reportNo: null,
          clientId: null,
          clientCode: null,
          clientName: null,
          machineryTypeId: null,
          machineryTypeCode: null,
          machineryTypeName: null,
          remark: null,
          createBy: null,
          createTime: null,
          fbStatus: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
          year: [
            { required: true, message: "年不能为空", trigger: "blur" }
          ],     
          month: [
            { required: true, message: "月不能为空", trigger: "blur" }
          ],     
          day: [
            { required: true, message: "日不能为空", trigger: "blur" }
          ], 
          rollNumber: [{ required: true, message: "原纸卷号不能为空", trigger: "blur" }],
          machineryCode: [{ required: true, message: "机台不能为空", trigger: "blur" }],
          workorderCode: [{ required: true, message: "工作单号不能为空", trigger: "blur" }],
          bagNumber: [{ required: true, message: "制袋数不能为空", trigger: "blur" }],
          workGroup: [{ required: true, message: "班次不能为空", trigger: "blur" }],
          quantityQualified: [{ required: true, message: "合格数不能为空", trigger: "blur" }],
        },
        // 导入参数
        upload: {
          // 是否显示弹出层
          open: false,
          // 弹出层标题
          title: "",
          // 是否禁用上传
          isUploading: false,
          // 是否更新已经存在的用户数据
          updateSupport: 0,
          // 设置上传的请求头部
          headers: {
            Authorization: "Bearer " + getToken()
          },
          // 上传的地址
          url: process.env.VUE_APP_BASE_API + "/mes/fb/reel/importData"
        },

      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询卷筒机报列表 */
      getList() {
        this.loading = true;
        this.queryParams.params = {};
        if (null != this.daterangeReportingDate && '' != this.daterangeReportingDate) {
            this.queryParams.params["beginReportingDate"] = this.daterangeReportingDate[0];
            this.queryParams.params["endReportingDate"] = this.daterangeReportingDate[1];
        }
        listReel(this.queryParams).then(response => {
          this.reelList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 生产工单选择弹出
      handleWorkorderSelect() {
        this.$refs.woSelect.showFlag = true;
      },
      // 生产工单选择回调
      onWorkorderSelected(row) {
        if (row != undefined && row != null) {
          this.form.workorderId = row.workorderId;
          this.form.workorderCode = row.workorderCode;
          this.form.workorderName = row.workorderName;
        }
      },
      //设备资源选择弹出
      handleMachineryAdd() {
        this.$refs.machinerySelect.showFlag = true;
      },
      //设备资源选择回调
      onMachineryAdd(row) {
        if (row != undefined && row != null) {
          this.form.machineryId = row.machineryId;
          this.form.machineryCode = row.machineryCode;
          this.form.machineryName = row.machineryName;
          this.form.machineryTypeId = row.machineryTypeId;
          this.form.machineryTypeCode = row.machineryTypeCode;
          this.form.machineryTypeName = row.machineryTypeName;
        }
      },
      /** 导入按钮操作 */
      handleImport() {
        this.upload.title = "报表导入";
        this.upload.open = true;
      },
      /** 下载模板操作 */
      importTemplate() {
        this.download('/mes/fb/reel/importTemplate', {}, `卷筒机报表模板.xlsx`)
      },
      // 文件上传中处理
      handleFileUploadProgress(event, file, fileList) {
        this.upload.isUploading = true;
      },
      // 文件上传成功处理
      handleFileSuccess(response, file, fileList) {
        this.upload.open = false;
        this.upload.isUploading = false;
        this.$refs.upload.clearFiles();
        this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
        this.getList();
      },
      // 提交上传文件
      submitFileForm() {
        this.$refs.upload.submit();
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          year: null, 
          month: null,
          day: null,
          recordId: null,
          machineryId: null,
          machineryCode: null,
          machineryName: null,
          leader: null,
          workorderId: null,
          workorderCode: null,
          workorderName: null,
          taskId: null,
          taskCode: null,
          rollNumber: null,
          itemId: null,
          itemCode: null,
          itemName: null,
          bagNumber: null,
          bagMeters: null,
          workGroup: null,
          bagWasteNumber: 0,
          printingWasteNumber: 0,
          reworkNumber: 0,
          materialHeadWeight: null,
          formingMaterial: null,
          bagWasteWeight: null,
          wasteWeight: null,
          quantityQualified: null,
          itemWeight: null,
          proSituation: null,
          changeSpc: null,
          hour: null,
          abnormalShutdown: null,
          profession: null,
          attendanceTime: null,
          assistant1: null,
          attendanceTime1: null,
          assistant2: null,
          attendanceTime2: null,
          workerNumber: null,
          leaderWages: null,
          assistant1Wages: null,
          assistant2Wages: null,
          wages: null,
          reportNo: null,
          clientId: null,
          clientCode: null,
          clientName: null,
          machineryTypeId: null,
          machineryTypeCode: null,
          machineryTypeName: null,
          remark: null,
          delFlag: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.daterangeReportingDate = []
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.recordId)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加卷筒机报";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const recordId = row.recordId || this.ids
        getReel(recordId).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改卷筒机报";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.recordId != null) {
              updateReel(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addReel(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const recordIds = row.recordId || this.ids;
        this.$modal.confirm('是否确认删除卷筒机报编号为"' + recordIds + '"的数据项？').then(function() {
          return delReel(recordIds);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
      },
      // 导出前参数操作
      
      /** 导出按钮操作 */
      handleExport() {
        this.beforeExportFn();
        this.download('/mes/fb/reel/export', {
          ...this.queryParams
        }, `卷筒机日报_${parseTime(new Date().getTime(), '{y}-{m}-{d}-{h}')}.xlsx`)
      }
    }
  };
</script>
<style scoped>
.upTime >>> .el-input{
  width: 201px;
}
</style>
